#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //给action设置快捷键
    QMenuBar* menuBar=new QMenuBar();
    this->setMenuBar(menuBar);

    QMenu* menu1=new QMenu("文件(&F)");//设置快捷键Alt+F
    QMenu* menu2=new QMenu("编辑(&E)");
    QMenu* menu3=new QMenu("视图(&V)");
    QMenu* menu4=new QMenu("关于(&A)");
    menuBar->addMenu(menu1);
    menuBar->addMenu(menu2);
    menuBar->addMenu(menu3);
    menuBar->addMenu(menu4);

    QAction* action1=new QAction("选项1");
    QAction* action2=new QAction("选项2");
    QAction* action3=new QAction("选项3");
    menu1->addAction(action1);
    menu1->addAction(action2);
    menu1->addAction(action3);
}

MainWindow::~MainWindow()
{
    delete ui;
}

